﻿#include <iostream>
#include <string>
using namespace std;
int main() {
    string s1;
    string s;
    setlocale(LC_ALL, "Russian");
    cout << "Введите скобочную последовательность: ";
    cin >> s;
    for (char c : s) {
        if (c == '(') {
            s1 += c;
        }
        if (c == ')') {
            if (s1.length() > 0) {
                if (s1[s1.length() - 1] == '(') {
                    s1.pop_back();
                }
            }
        }
        if (c == '[') {
            s1 += c;
        }
        if (c == ']') {
            if (s1.length() > 0) {
                if (s1[s1.length() - 1] == '[') {
                    s1.pop_back();
                }
            }
        }
        if (c == '<') {
            s1 += c;
        }
        if (c == '>') {
            if (s1.length() > 0) {
                if (s1[s1.length() - 1] == '<') {
                    s1.pop_back();
                }
            }
        }
        if (c == '{') {
            s1 += c;
        }
        if (c == '}') {
            if (s1.length() > 0) {
                if (s1[s1.length() - 1] == '{') {
                    s1.pop_back();
                }
            }
        }
    }
    if (s1.length() > 0)
    {
        cout << "False" << endl;
    }
    else
    {
        cout << "True" << endl;
    }
    return 0;
}